<div
    bsModal
    #createOrEditModal="bs-modal"
    class="modal fade"
    tabindex="-1"
    role="dialog"
    aria-labelledby="createOrEditModal"
    aria-hidden="true"
    [config]="{ backdrop: 'static' }"
    (onHidden)="onHidden($event)"
    (onShown)="shown()"
>
    <div class="modal-dialog modal-xxl">
        <div class="modal-content">
            <form #editForm="ngForm" novalidate autocomplete="off">
                <div class="modal-header">
                    <h4 class="modal-title">
                        台帐信息
                    </h4>
                    <button type="button" class="close" (click)="cancel()" [attr.aria-label]="l('Close')">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="m-subheader">
                    <div class="row">
                        <div class="col-md-11">
                            <div class="row align-items-center">
                                <div class="input-width">
                                    <div class="form-group m-form__group row">
                                        <label
                                            class="col-5 col-form-label"
                                            for="f_MaterialName"
                                            style="text-align: right;"
                                            >物料名称:</label
                                        >
                                        <div class="col-7">
                                            <input
                                                type="text"
                                                class="form-control m-input"
                                                name="f_MaterialName"
                                                id="f_MaterialName"
                                                [(ngModel)]="f_MaterialName"
                                            />
                                        </div>
                                    </div>
                                </div>
                                <div class="input-width">
                                    <div class="form-group m-form__group row">
                                        <label
                                            class="col-5 col-form-label"
                                            for="f_MaterialCode"
                                            style="text-align: right;"
                                            >物料编号:</label
                                        >
                                        <div class="col-7">
                                            <input
                                                type="text"
                                                class="form-control m-input"
                                                name="f_MaterialCode"
                                                id="f_MaterialCode"
                                                [(ngModel)]="f_MaterialCode"
                                            />
                                        </div>
                                    </div>
                                </div>
                                <div class="input-width">
                                    <div class="form-group m-form__group row">
                                        <label class="col-4 col-form-label" for="f_TradeMark" style="text-align: right;"
                                            >品牌:</label
                                        >
                                        <div class="col-8">
                                            <input
                                                type="text"
                                                class="form-control m-input"
                                                name="f_TradeMark"
                                                id="f_TradeMark"
                                                [(ngModel)]="f_TradeMark"
                                            />
                                        </div>
                                    </div>
                                </div>
                                <div class="input-width">
                                    <div class="form-group m-form__group row">
                                        <label class="col-4 col-form-label" for="f_Station" style="text-align: right;"
                                            >状态:</label
                                        >
                                        <div class="col-8">
                                            <input
                                                type="text"
                                                class="form-control m-input"
                                                name="f_Station"
                                                id="f_Station"
                                                [(ngModel)]="f_Station"
                                            />
                                        </div>
                                    </div>
                                </div>
                                <div class="input-width">
                                    <div class="form-group m-form__group row">
                                        <label
                                            class="col-5 col-form-label"
                                            for="f_TecCondition"
                                            style="text-align: right;"
                                            >技术条件:</label
                                        >
                                        <div class="col-7">
                                            <input
                                                type="text"
                                                class="form-control m-input"
                                                name="f_TecCondition"
                                                id="f_TecCondition"
                                                [(ngModel)]="f_TecCondition"
                                            />
                                        </div>
                                    </div>
                                </div>

                                <div class="input-width">
                                    <div class="form-group m-form__group row">
                                        <label
                                            class="col-4 col-form-label"
                                            for="Search_MaterialName"
                                            style="text-align: right;"
                                            >数量:</label
                                        >
                                        <div class="col-8">
                                            <camc-dropdown-auto
                                                [options]="useableOptions"
                                                name="isuseable"
                                                [(ngModel)]="isuseable"
                                                class="float-left"
                                                [style]="{ width: '130px' }"
                                            >
                                            </camc-dropdown-auto>
                                        </div>
                                    </div>
                                </div>
                                <div class="input-width">
                                    <div class="form-group m-form__group row">
                                        <label class="col-4 col-form-label" for="warehouseNameFilter">仓库:</label>
                                        <div class="col-8">
                                            <camc-multiSelect
                                                class="float-left"
                                                id="warehouseNameFilter"
                                                [options]="roomOption"
                                                name="tabdle"
                                                [(ngModel)]="selectedWareHouse"
                                                [style]="{ width: '220px' }"
                                                styleClass="form-control"
                                                defaultLabel="选择仓库"
                                                maxSelectedLabels="1"
                                                selectedItemsLabel="已选择{0}个仓库"
                                            >
                                            </camc-multiSelect>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-1 m--align-right">
                            <button (click)="getBaseAccount()" class="btn btn-primary m--margin-top-40" type="button">
                                <i class="flaticon-search-1" [attr.aria-label]="l('Search')"></i>查询
                            </button>
                        </div>
                    </div>

                    <div class="row align-items-center">
                        <div class="col-md-6"></div>
                        <div class="col-md-6"></div>
                    </div>
                </div>
                <div class="modal-body">
                    <div class="m-portlet__body" style="border-top: 1px solid #ebedf2;  margin-top: 11px;">
                        <h4>台帐信息</h4>
                        <div class="tabbable-line">
                            <div class="tab-content" style="padding-top:0;">
                                <div class="tab-pane active" id="tab-model">
                                    <div class="row align-items-center">
                                        <div
                                            class="primeng-datatable-container"
                                            [busyIf]="primengTableHelper.isLoading"
                                        >
                                            <p-table
                                                #dataTable
                                                (onLazyLoad)="getRecordsIfNeeds($event)"
                                                [value]="primengTableHelper.records"
                                                [rows]="primengTableHelper.defaultRecordsCountPerPage"
                                                [paginator]="false"
                                                [lazy]="true"
                                                [scrollable]="true"
                                                ScrollWidth="100%"
                                                [responsive]="primengTableHelper.isResponsive"
                                                [resizableColumns]="primengTableHelper.resizableColumns"
                                                [(selection)]="selectedValue"
                                                selectionMode="multiple"
                                            >
                                                <ng-template pTemplate="header">
                                                    <tr>
                                                        <th style="width: 25px">
                                                            <p-tableHeaderCheckbox></p-tableHeaderCheckbox>
                                                        </th>
                                                        <th style="width: 40px">
                                                            序号
                                                        </th>
                                                        <ng-container *ngFor="let ext of extensions">
                                                            <th width="{{ ext.width }}">
                                                                {{ ext.title }}
                                                            </th>
                                                        </ng-container>
                                                    </tr>
                                                </ng-template>

                                                <ng-template pTemplate="body" let-record="$implicit" let-i="rowIndex">
                                                    <tr [pSelectableRow]="record">
                                                        <td style="width: 25px">
                                                            <p-tableCheckbox [value]="record"></p-tableCheckbox>
                                                        </td>
                                                        <td style="width: 40px">
                                                            {{ i + 1 + paginator.first }}
                                                        </td>
                                                        <ng-container *ngFor="let ext of extensions">
                                                            <ng-container [ngSwitch]="ext.formatType">
                                                                <ng-container *ngSwitchCase="1">
                                                                    <td width="{{ ext.width }}">
                                                                        {{ record[ext.key] | number: '1.0-0' }}
                                                                    </td>
                                                                </ng-container>
                                                                <ng-container *ngSwitchCase="2">
                                                                    <td width="{{ ext.width }}">
                                                                        {{ record[ext.key] | number: '1.2-2' }}
                                                                    </td>
                                                                </ng-container>
                                                                <ng-container *ngSwitchCase="4">
                                                                    <td width="{{ ext.width }}">
                                                                        {{
                                                                            record[ext.key] | momentFormat: 'YYYY-MM-DD'
                                                                        }}
                                                                    </td>
                                                                </ng-container>
                                                                <ng-container *ngSwitchDefault>
                                                                    <td width="{{ ext.width }}" style="text-align:right;" *ngIf="ext.key == 'f_UsableSum' || ext.key=='f_RealInventory' || ext.key=='f_RealUsable' || ext.key=='f_RealReservation' || ext.key=='f_OnOrderQTY' || ext.key=='f_OrderedQTY'">
                                                                        {{ record[ext.key] | number: '1.3-3' }}
                                                                    </td>
                                                                    <td
                                                                        width="{{ ext.width }}"
                                                                        style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"
                                                                        *ngIf="!(ext.key == 'f_UsableSum' || ext.key=='f_RealInventory' || ext.key=='f_RealUsable' || ext.key=='f_RealReservation' || ext.key=='f_OnOrderQTY' || ext.key=='f_OrderedQTY')"
                                                                    >
                                                                        {{ record[ext.key] }}
                                                                    </td>
                                                                </ng-container>
                                                            </ng-container>
                                                        </ng-container>
                                                    </tr>
                                                </ng-template>
                                            </p-table>

                                            <div class="primeng-paging-container">
                                                <p-paginator
                                                    [rows]="20"
                                                    #paginator
                                                    (onPageChange)="getRecordsIfNeeds($event)"
                                                    [totalRecords]="primengTableHelper.totalRecordsCount"
                                                    [rowsPerPageOptions]="
                                                        primengTableHelper.predefinedRecordsCountPerPage
                                                    "
                                                >
                                                </p-paginator>
                                                <span class="total-records-count">
                                                    {{ l('TotalRecordsCount', primengTableHelper.totalRecordsCount) }}
                                                </span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button [disabled]="saving" type="button" class="btn btn-default" (click)="cancel()">
                            {{ l('Cancel') }}
                        </button>
                        <button
                            (click)="save()"
                            type="button"
                            class="btn btn-primary blue"
                            [disabled]="!editForm.form.valid"
                            [buttonBusy]="saving"
                            [busyText]="l('SavingWithThreeDot')"
                        >
                            <i class="fa fa-save"></i>
                            <span>{{ l('Save') }}</span>
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
